<% form_for :user, @user, :url => { :id => @user.id, :action => 'create' }, :html => { :id =>'user_create_form', :method => @user.id.nil? ?  :post : :put} do |f| %>
  <fieldset>
    <div class="modal-head">
      <h2>Add new user</h2>
    </div>
    <div class="modal-body">
      <% if @errors
           @errors.each do |error|
      %>
          <p class="error"><%= h error -%></p>
      <% end
         end
      %>
      <div class="modal-field"><label for="user[login]">Login <em class="mandatory">*</em></label>
        <% if @user.id %>
          <%= @user.login %>
          <%= f.hidden_field :login %>
        <% else %>
          <%= f.text_field :login, :size => 30, :maxLength => 255 %>
        <% end %>
      </div>
      <div class="modal-field">
          <label for="user[]">Name <em class="mandatory">*</em></label>
          <%= f.text_field :name, :size => 30, :maxLength => 200 %></div>
      <div class="modal-field">
          <label for="user[]">Email</label>
          <%= f.text_field :email, :size => 30, :maxLength => 100 %></div>
      <div class="modal-field"><label for="user[password]">Password <em class="mandatory">*</em></label><%= f.password_field :password, :size => 30, :maxLength => 50, :autocomplete => 'off' %></div>
      <div class="modal-field"><label for="user[password_confirmation]">Confirm password <em class="mandatory">*</em></label><%= f.password_field :password_confirmation, :size => 30, :maxLength => 50, :autocomplete => 'off' %></div>

    </div>
      <div class="modal-foot">
          <%= submit_tag 'Create' %>
          <%= link_to 'Cancel', { :controller => 'users', :action => 'index'}, { :class => 'action' } %><br/>
      </div>
  </fieldset>
<% end %>

<script>
  $j("#user_create_form").modalForm();
</script>
